from django.db import models
from django.contrib import admin
# Create your models here.

class Tag(models.Model):
	name = models.CharField(max_length="20", primary_key="true")

	def __unicode__(self):
      	  return self.name

class Post(models.Model):
	title = models.CharField(max_length="20", primary_key="true")
	author = models.CharField(max_length="20")
	slug = models.SlugField(unique="true")
	content = models.TextField(blank="true")
   	date = models.DateTimeField()
	tags = models.ManyToManyField(Tag)


	def __unicode__(self):
      	  return self.title
	
	def get_absolute_url(self):
   	 return "/blog/%s/" % self.slug

class PostAdmin(admin.ModelAdmin):
	list_display = ('title', 'author', 'date')

admin.site.register(Post, PostAdmin)
admin.site.register(Tag)
  	


	


